﻿using System;
using System.Collections.Generic;
using System.Linq;

namespace BigMonitoringWarningApi.Tool.Extension
{
    public static partial class GyctExtention
    {

        public static List<string> Tonull(this List<string> dateTonul)
        {
            List<string> vs = new List<string>();
            foreach (var item in dateTonul)
            {
                if (!string.IsNullOrWhiteSpace(item))
                    vs.Add(item);
            }
            return vs;
        }
        /// <summary>
        /// 检查字符串是否为空或者为全空白字符串
        /// </summary>
        /// <param name="str">字符串</param>
        /// <returns></returns>
        public static bool IsEmpty(this string str)
        {
            if (string.IsNullOrEmpty(str) || string.IsNullOrWhiteSpace(str))
                return true;
            return false;
        }
        /// <summary>
        /// 是否为空
        /// </summary>
        /// <param name="value">值</param>
        public static bool IsEmpty(this Guid? value)
        {
            if (value == null)
                return true;
            return IsEmpty(value.Value);
        }
        /// <summary>
        /// 是否为空
        /// </summary>
        /// <param name="value">值</param>
        public static bool IsEmpty(this Guid value)
        {
            if (value == Guid.Empty)
                return true;
            return false;
        }
        /// <summary>
        /// 是否为空
        /// </summary>
        /// <param name="value">值</param>
        public static bool IsEmpty(this object value)
        {
            if (value != null && !value.ToString().IsEmpty())
                return false;
            else
                return true;
        }
        /// <summary>
        /// 判断是否为空
        /// </summary>
        /// <typeparam name="T">Model</typeparam>
        /// <param name="value">值</param>
        /// <returns></returns>
        public static bool IsEmpty<T>(this List<T> value)
        {
            if (value != null && value.Any())
            {
                return false;
            }
            return true;
        }
    }
}
